Skip to content

Clean up low-severity CodeQL code-quality alerts#299

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/codeql-quality-notes
Jul 23, 2026
Merged

Clean up low-severity CodeQL code-quality alerts#299
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/codeql-quality-notes

Conversation

@vharseko

Copy link
Copy Markdown
Member

Resolves 17 open CodeQL note-level (code-quality) alerts across 15 files. All changes are behaviour-preserving mechanical cleanups.

Fixes by rule

Rule Count Change
java/inefficient-empty-string-test 8 "".equals(x) / x.equals("")x.isEmpty() (each site already null-guards separately)
java/inefficient-string-constructor 2 drop redundant new String(url.toString()) wrapper
java/inefficient-key-set-iterator 2 iterate entrySet() instead of keySet() + get(key) (identical output)
java/useless-tostring-call 2 remove .toString() on a value that is already a String
java/local-variable-is-never-read 3 remove dead local assignments

Intentionally left alone (not mechanical)

These open alerts are not included, as a "fix" would be wrong or would change behaviour:

  • persistit/core/.../BufferPool.java:272 (local-variable-is-never-read) — deliberate OOM reserve: the byte[] reserve block is nulled in the catch to free memory for the diagnostic path. Removing it would break the mechanism (false positive).
  • rest/api-descriptor/.../CrestApiProducer.java:93 (call-to-object-tostring) — no clean mechanical fix; a change would alter the text of a diagnostic exception message.
  • persistit/doc/conf.py:14 (py/unused-import) — import sys, os backs the commented Sphinx example on line 19; removing it would introduce a latent NameError.

Verification

mvn -o compile passes for every touched Maven module; AsciiDocIndex.java (non-Maven doc tooling) compiles via javac with persistit-core on the classpath.

Resolve 17 CodeQL note-level alerts across 15 files:
- inefficient-empty-string-test: use String.isEmpty() instead of ""-equality (8)
- inefficient-string-constructor: drop redundant new String(...) wrappers (2)
- inefficient-key-set-iterator: iterate entrySet() instead of keySet()+get() (2)
- useless-tostring-call: remove toString() on values already String (2)
- local-variable-is-never-read: remove dead local assignments (3)

Behaviour is unchanged; all touched modules compile.
@vharseko
vharseko requested a review from maximthomas July 23, 2026 15:41
@vharseko vharseko added codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change labels Jul 23, 2026
@vharseko
vharseko merged commit a65eeef into OpenIdentityPlatform:master Jul 23, 2026
14 checks passed
@vharseko
vharseko deleted the fix/codeql-quality-notes branch July 23, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants